package com.zmj.sy.mom.srv.aps.controller;


import com.zmj.sy.mom.srv.aps.bean.vo.base.BaseIdsReqVo;
import com.zmj.sy.mom.srv.aps.bean.vo.base.BaseResVo;
import com.zmj.sy.mom.srv.aps.bean.vo.base.BaseSelectResVo;
import com.zmj.sy.mom.srv.aps.bean.vo.change.*;
import com.zmj.sy.mom.srv.aps.service.ChangeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RequiredArgsConstructor
@Api(tags = "变更处理")
@RestController
@RequestMapping("/change")
public class ChangeController {

    private final ChangeService changeService;

    @ApiOperation("BOM 新增")
    @PostMapping("/bomAdd")
    public BaseResVo bomAdd(@RequestBody ChangeBomAddReqVo reqVo) {
        changeService.bomAdd(reqVo);
        return BaseResVo.ok();
    }

    @ApiOperation("BOM 修改")
    @PostMapping("/bomEdit")
    public BaseResVo bomEdit(@RequestBody ChangeBomEditReqVo reqVo) {
        changeService.bomEdit(reqVo);
        return BaseResVo.ok();
    }

    @ApiOperation("BOM 删除")
    @PostMapping("/bomDel")
    public BaseResVo bomDel(@RequestBody ChangeBomDelReqVo reqVo) {
        changeService.bomDel(reqVo.getId());
        return BaseResVo.ok();
    }

    @ApiOperation("工序 修改")
    @PostMapping("/phaseEdit")
    public BaseResVo phaseEdit(@RequestBody ChangePhaseEditReqVo reqVo) {
        changeService.phaseEdit(reqVo);
        return BaseResVo.ok();
    }

    @ApiOperation("工序 删除")
    @PostMapping("/phaseDel")
    public BaseResVo phaseDel(@RequestBody ChangePhaseDelReqVo reqVo) {
        changeService.phaseDel(reqVo);
        return BaseResVo.ok();
    }


    @ApiOperation("自制件转外购件")
    @PostMapping("/partToComponent")
    public BaseResVo partToComponent(@RequestBody BaseIdsReqVo reqVo){
        changeService.partToComponent(reqVo);
        return BaseResVo.ok();
    }

    @ApiOperation("外购件转自制件")
    @PostMapping("/componentToPart")
    public BaseResVo componentToPart(@RequestBody ChangeComponentToPartReqVo reqVo) {
        changeService.componentToPart(reqVo);
        return BaseResVo.ok();
    }


    // ----------- 以下是查询------------------
    @ApiOperation("查找ERP工作中心")
    @GetMapping("/erpWorkCenter")
    public BaseSelectResVo erpWorkCenter(ChangeErpWorkCenterReqVo reqVo) {
        return BaseSelectResVo.of(changeService.erpWorkCenter(reqVo));
    }

    @ApiOperation("查找ERP工序")
    @GetMapping("/erpPhase")
    public BaseSelectResVo erpPhase(ChangeErpPhaseReqVo reqVo) {
        return BaseSelectResVo.of(changeService.erpPhase(reqVo));
    }

    @ApiOperation("ERP转APS工序")
    @GetMapping("/erpToAps")
    public ChangeErpToApsResVo erpToAps(ChangeErpToApsReqVo reqVo) {
        return changeService.erpToAps(reqVo);
    }



}
